﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using DAO_ADMIN;

namespace PTTK19.GUI
{
    class DBThucDon
    {
        internal static DataTable GetList()
        {
            //DBMS dbms = new DBMS();
            string procname = "sp_LayDanhSachThucDon";
            DataTable dt = DataProvider.SelectStoreProcedure(procname);
            return dt;
        }


        internal static bool AddThucDon(string _TenMonAn, int _TinhTrang)
        {
            bool kq = false;
            try
            {
                List<SqlParameter> parr = new List<SqlParameter>();
                string procname = "sp_ThemThucDon";
                parr.Add(new SqlParameter("@TenMonAn", _TenMonAn));
                parr.Add(new SqlParameter("@CachCheBien", _TinhTrang));
                DataProvider.NonqueryProc(procname, parr);
                kq = true;
            }
            catch (Exception)
            {
            }
            return kq;
        }

        internal static bool UpdateThucDon(int _MaThucDon, string _TenThucDon, int _TinhTrang)
        {
            bool kq = false;
            try
            {
                List<SqlParameter> parr = new List<SqlParameter>();
                string procname = "sp_UpdateThucDon";
                parr.Add(new SqlParameter("@MaThucDon", _MaThucDon));
                parr.Add(new SqlParameter("@TenThucDon", _TenThucDon));
                parr.Add(new SqlParameter("@TinhTrang", _TinhTrang));
                DataProvider.NonqueryProc(procname, parr);
                kq = true;
            }
            catch (Exception)
            {
            }
            return kq;
        }

        internal static bool DelThucDon(int _MaThucDon)
        {
            bool kq = false;
            try
            {
                List<SqlParameter> parr = new List<SqlParameter>();
                string procname = "sp_DelThucDon";
                parr.Add(new SqlParameter("@MaThucDon", _MaThucDon));
                DataProvider.NonqueryProc(procname, parr);
                kq = true;
            }
            catch (Exception)
            {
            }
            return kq;
        }

        internal static DataTable GetListID()
        {
            string procname = "sp_DSMaThucDonTonTai";
            DataTable dt = DataProvider.SelectStoreProcedure(procname);
            return dt;
        }
    }
}
